package cn.com.css.taxInspection.workquality.controller;

import java.util.Calendar;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.baomidou.mybatisplus.core.metadata.IPage;

import cn.com.css.taxInspection.common.result.DataResult;
import cn.com.css.taxInspection.gt3.entity.JcAjztTjBjDlEntity;
import cn.com.css.taxInspection.gt3.entity.JcAjztTjBjEntity;
import cn.com.css.taxInspection.gt3.entity.JcAjztTjEntity;
import cn.com.css.taxInspection.gt3.entity.JcAjztTjJcDlEntity;
import cn.com.css.taxInspection.gt3.entity.JcAjztTjJcEntity;
import cn.com.css.taxInspection.gt3.entity.JcAjztTjQbEntity;
import cn.com.css.taxInspection.gt3.entity.JcAjztTjRyEntity;
import cn.com.css.taxInspection.gt3.entity.JcAjztTjSlDlEntity;
import cn.com.css.taxInspection.gt3.entity.JcAjztTjSlEntity;
import cn.com.css.taxInspection.gt3.entity.JcAjztTjZjjcDlEntity;
import cn.com.css.taxInspection.gt3.entity.JcAjztTjZjjcEntity;
import cn.com.css.taxInspection.gt3.entity.JcAjztTjZstsEntity;
import cn.com.css.taxInspection.gt3.entity.JcAjztTjZxDlEntity;
import cn.com.css.taxInspection.gt3.entity.JcAjztTjZxEntity;
import cn.com.css.taxInspection.gt3.entity.JcAjztTjZxwbDlEntity;
import cn.com.css.taxInspection.gt3.entity.JcAjztTjZxwbEntity;
import cn.com.css.taxInspection.gt3.service.JcAjztTjBjDlService;
import cn.com.css.taxInspection.gt3.service.JcAjztTjBjService;
import cn.com.css.taxInspection.gt3.service.JcAjztTjJcDlService;
import cn.com.css.taxInspection.gt3.service.JcAjztTjJcService;
import cn.com.css.taxInspection.gt3.service.JcAjztTjQbService;
import cn.com.css.taxInspection.gt3.service.JcAjztTjRyService;
import cn.com.css.taxInspection.gt3.service.JcAjztTjService;
import cn.com.css.taxInspection.gt3.service.JcAjztTjSlDlService;
import cn.com.css.taxInspection.gt3.service.JcAjztTjSlService;
import cn.com.css.taxInspection.gt3.service.JcAjztTjZjjcDlService;
import cn.com.css.taxInspection.gt3.service.JcAjztTjZjjcService;
import cn.com.css.taxInspection.gt3.service.JcAjztTjZstsService;
import cn.com.css.taxInspection.gt3.service.JcAjztTjZxDlService;
import cn.com.css.taxInspection.gt3.service.JcAjztTjZxService;
import cn.com.css.taxInspection.gt3.service.JcAjztTjZxwbDlService;
import cn.com.css.taxInspection.gt3.service.JcAjztTjZxwbService;
import cn.com.css.taxInspection.system.service.impl.HttpSessionService;
import cn.com.css.taxInspection.util.TsBqUtils;
import cn.com.css.taxInspection.workflow.entity.WorkflowCompensateEntity;
import cn.com.css.taxInspection.workflow.service.WorkflowCompensateService;
import cn.com.css.taxInspection.workquality.vo.req.SelectchiefReqVo;

@Controller
@RequestMapping("/workflow/mianSelectchief")
public class MianSelectchiefController {
	@Autowired
	private HttpSessionService httpSessionService;
	@Autowired
	private JcAjztTjService jcAjztTjService;
	@Autowired
	private JcAjztTjRyService jcAjztTjRyService;

	@Autowired
	private JcAjztTjQbService jcAjztTjQbService;
	
	// JC_AJZT_TJ_JC
	@Autowired
	private JcAjztTjJcService jcAjztTjJcService;
	@Autowired
	private JcAjztTjJcDlService jcAjztTjJcDlService;
	
	// Jc_Ajzt_Tj_Zsts
	@Autowired
	private JcAjztTjZstsService jcAjztTjZstsService;
	
	// JC_AJZT_TJ_SL
	@Autowired
	private JcAjztTjSlService jcAjztTjSlService;
	@Autowired
	private JcAjztTjSlDlService jcAjztTjSlDlService;
	
	// JC_AJZT_TJ_ZX
	@Autowired
	private JcAjztTjZxService jcAjztTjZxService;
	@Autowired
	private JcAjztTjZxDlService jcAjztTjZxDlService;
	
	// JC_AJZT_TJ_ZXWB
	@Autowired
	private JcAjztTjZxwbService jcAjztTjZxwbService;
	@Autowired
	private JcAjztTjZxwbDlService jcAjztTjZxwbDlService;
	
	// JC_AJZT_TJ_ZJJC
	@Autowired
	private JcAjztTjZjjcService jcAjztTjZjjcService;
	@Autowired
	private JcAjztTjZjjcDlService jcAjztTjZjjcDlService;
	
	// JC_AJZT_TJ_BJ
	@Autowired
	private JcAjztTjBjService jcAjztTjBjService;
	@Autowired
	private JcAjztTjBjDlService jcAjztTjBjDlService;
	
	@Resource
	private WorkflowCompensateService workflowCompensateService;
	
	
	@PostMapping("/one")
	@ResponseBody
	public DataResult one() {
		String currentDeptId = httpSessionService.getCurrentDeptId();
		Calendar calendar = Calendar.getInstance();
		int year = calendar.get(Calendar.YEAR);
		List<JcAjztTjEntity> list = jcAjztTjService.list(currentDeptId, String.valueOf(year));
		return DataResult.success(list);
	}

	@PostMapping("/two/jssl")
	@ResponseBody
	public DataResult twoJssl(@RequestBody SelectchiefReqVo selectchiefReqVo) {
		String currentDeptId = httpSessionService.getCurrentDeptId();
		Calendar calendar = Calendar.getInstance();
		int year = calendar.get(Calendar.YEAR);
		JcAjztTjRyEntity jcAjztTjRyEntity = new JcAjztTjRyEntity();
		jcAjztTjRyEntity.setNd(String.valueOf(year));
		jcAjztTjRyEntity.setSwjgDm(currentDeptId);
		
		jcAjztTjRyEntity.setPage(selectchiefReqVo.getPage());
		jcAjztTjRyEntity.setLimit(selectchiefReqVo.getLimit());
		
		IPage<JcAjztTjRyEntity> infoPage = jcAjztTjRyService.infoPage(jcAjztTjRyEntity);

		return DataResult.success(infoPage);

	}

	@PostMapping("/two/zzjcsl")
	@ResponseBody
	public DataResult twoZzjcsl(@RequestBody SelectchiefReqVo selectchiefReqVo) {
		String currentDeptId = httpSessionService.getCurrentDeptId();
		// JC_AJZT_TJ_JC
		Calendar calendar = Calendar.getInstance();
		int year = calendar.get(Calendar.YEAR);
		JcAjztTjJcEntity jcAjztTjJcEntity = new JcAjztTjJcEntity();
		jcAjztTjJcEntity.setNd(String.valueOf(year));
		jcAjztTjJcEntity.setSwjgDm(currentDeptId);
		
		jcAjztTjJcEntity.setPage(selectchiefReqVo.getPage());
		jcAjztTjJcEntity.setLimit(selectchiefReqVo.getLimit());
		
		/*IPage<JcAjztTjJcEntity> infoPage = jcAjztTjJcService.infoPage(jcAjztTjJcEntity);*/
		IPage<JcAjztTjJcDlEntity> infoPage = jcAjztTjJcDlService.infoPage(jcAjztTjJcEntity);
		
		// 是否申请公安联合办案
		List<JcAjztTjJcDlEntity> records = infoPage.getRecords();
		for (JcAjztTjJcDlEntity jcAjztTjJc : records) {
			String jcajxxuuid = jcAjztTjJc.getJcajxxuuid();
			WorkflowCompensateEntity workflowCompensate = workflowCompensateService.getByJcajxxuuid(jcajxxuuid);
			if(TsBqUtils.isNotNull(workflowCompensate)){
				jcAjztTjJc.setIsSqgalhba(workflowCompensate.getIsSqgalhba());
			}
			
		}
		
		return DataResult.success(infoPage);

	}

	@PostMapping("/two/yjslsl")
	@ResponseBody
	public DataResult twoYjslsl(@RequestBody SelectchiefReqVo selectchiefReqVo) {
		String currentDeptId = httpSessionService.getCurrentDeptId();
		// JC_AJZT_TJ_SL

		Calendar calendar = Calendar.getInstance();
		int year = calendar.get(Calendar.YEAR);
		JcAjztTjSlEntity jcAjztTjSlEntity = new JcAjztTjSlEntity();
		jcAjztTjSlEntity.setNd(String.valueOf(year));
		jcAjztTjSlEntity.setSwjgDm(currentDeptId);
		
		jcAjztTjSlEntity.setPage(selectchiefReqVo.getPage());
		jcAjztTjSlEntity.setLimit(selectchiefReqVo.getLimit());
		
		/*IPage<JcAjztTjSlEntity> infoPage = jcAjztTjSlService.infoPage(jcAjztTjSlEntity);*/
		IPage<JcAjztTjSlDlEntity> infoPage = jcAjztTjSlDlService.infoPage(jcAjztTjSlEntity);
		return DataResult.success(infoPage);

	}

	@PostMapping("/two/yjzxsl")
	@ResponseBody
	public DataResult twoYjzxsl(@RequestBody SelectchiefReqVo selectchiefReqVo) {
		String currentDeptId = httpSessionService.getCurrentDeptId();
		// JC_AJZT_TJ_ZX

		Calendar calendar = Calendar.getInstance();
		int year = calendar.get(Calendar.YEAR);
		JcAjztTjZxEntity jcAjztTjZxEntity = new JcAjztTjZxEntity();
		jcAjztTjZxEntity.setNd(String.valueOf(year));
		jcAjztTjZxEntity.setSwjgDm(currentDeptId);
		
		jcAjztTjZxEntity.setPage(selectchiefReqVo.getPage());
		jcAjztTjZxEntity.setLimit(selectchiefReqVo.getLimit());
		
		/*IPage<JcAjztTjZxEntity> infoPage = jcAjztTjZxService.infoPage(jcAjztTjZxEntity);*/
		IPage<JcAjztTjZxDlEntity> infoPage = jcAjztTjZxDlService.infoPage(jcAjztTjZxEntity);
		return DataResult.success(infoPage);

	}

	@PostMapping("/two/jasl1")
	@ResponseBody
	public DataResult twoJasl1(@RequestBody SelectchiefReqVo selectchiefReqVo) {
		String currentDeptId = httpSessionService.getCurrentDeptId();
		// JC_AJZT_TJ_ZXWB

		Calendar calendar = Calendar.getInstance();
		int year = calendar.get(Calendar.YEAR);
		JcAjztTjZxwbEntity jcAjztTjZxwbEntity = new JcAjztTjZxwbEntity();
		jcAjztTjZxwbEntity.setNd(String.valueOf(year));
		jcAjztTjZxwbEntity.setSwjgDm(currentDeptId);
		
		
		jcAjztTjZxwbEntity.setPage(selectchiefReqVo.getPage());
		jcAjztTjZxwbEntity.setLimit(selectchiefReqVo.getLimit());
		
		/*IPage<JcAjztTjZxwbEntity> infoPage = jcAjztTjZxwbService.infoPage(jcAjztTjZxwbEntity);*/
		IPage<JcAjztTjZxwbDlEntity> infoPage = jcAjztTjZxwbDlService.infoPage(jcAjztTjZxwbEntity);
		return DataResult.success(infoPage);
	}

	@PostMapping("/two/jasl2")
	@ResponseBody
	public DataResult twoJasl2(@RequestBody SelectchiefReqVo selectchiefReqVo) {
		String currentDeptId = httpSessionService.getCurrentDeptId();
		// JC_AJZT_TJ_ZJJC
		
		Calendar calendar = Calendar.getInstance();
		int year = calendar.get(Calendar.YEAR);
		JcAjztTjZjjcEntity jcAjztTjZjjcEntity = new JcAjztTjZjjcEntity();
		jcAjztTjZjjcEntity.setNd(String.valueOf(year));
		jcAjztTjZjjcEntity.setSwjgDm(currentDeptId);
		
		jcAjztTjZjjcEntity.setPage(selectchiefReqVo.getPage());
		jcAjztTjZjjcEntity.setLimit(selectchiefReqVo.getLimit());
		
		/*IPage<JcAjztTjZjjcEntity> infoPage = jcAjztTjZjjcService.infoPage(jcAjztTjZjjcEntity);*/
		IPage<JcAjztTjZjjcDlEntity> infoPage = jcAjztTjZjjcDlService.infoPage(jcAjztTjZjjcEntity);
		return DataResult.success(infoPage);
	}

	@PostMapping("/two/jasl3")
	@ResponseBody
	public DataResult twoJasl3(@RequestBody SelectchiefReqVo selectchiefReqVo) {
		String currentDeptId = httpSessionService.getCurrentDeptId();
		// JC_AJZT_TJ_BJ

		Calendar calendar = Calendar.getInstance();
		int year = calendar.get(Calendar.YEAR);
		JcAjztTjBjEntity jcAjztTjBjEntity = new JcAjztTjBjEntity();
		jcAjztTjBjEntity.setNd(String.valueOf(year));
		jcAjztTjBjEntity.setSwjgDm(currentDeptId);
		
		jcAjztTjBjEntity.setPage(selectchiefReqVo.getPage());
		jcAjztTjBjEntity.setLimit(selectchiefReqVo.getLimit());
		
		
		/*IPage<JcAjztTjBjEntity> infoPage = jcAjztTjBjService.infoPage(jcAjztTjBjEntity);*/
		IPage<JcAjztTjBjDlEntity> infoPage = jcAjztTjBjDlService.infoPage(jcAjztTjBjEntity);
		
		return DataResult.success(infoPage);
	}

	@PostMapping("/three/jssl/jssl")
	@ResponseBody
	public DataResult threeJsslJssl(@RequestBody SelectchiefReqVo selectchiefReqVo) {
		// JC_AJZT_TJ_QB
		String currentDeptId = httpSessionService.getCurrentDeptId();
		
		Calendar calendar = Calendar.getInstance();
		int year = calendar.get(Calendar.YEAR);
		String swryDm = selectchiefReqVo.getSwryDm();

		JcAjztTjQbEntity jcAjztTjQbEntity = new JcAjztTjQbEntity();
		jcAjztTjQbEntity.setNd(String.valueOf(year));
		jcAjztTjQbEntity.setJcry(swryDm);
		jcAjztTjQbEntity.setSwjgDm(currentDeptId);
		
		jcAjztTjQbEntity.setPage(selectchiefReqVo.getPage());
		jcAjztTjQbEntity.setLimit(selectchiefReqVo.getLimit());
		
		IPage<JcAjztTjQbEntity> infoPage = jcAjztTjQbService.infoPage(jcAjztTjQbEntity);

		return DataResult.success(infoPage);

	}

	@PostMapping("/three/jssl/zzjcsl")
	@ResponseBody
	public DataResult threeJsslZzjcsl(@RequestBody SelectchiefReqVo selectchiefReqVo) {
		// JC_AJZT_TJ_JC
		String currentDeptId = httpSessionService.getCurrentDeptId();
		
		Calendar calendar = Calendar.getInstance();
		int year = calendar.get(Calendar.YEAR);
		String swryDm = selectchiefReqVo.getSwryDm();

		JcAjztTjJcEntity jcAjztTjJcEntity = new JcAjztTjJcEntity();
		jcAjztTjJcEntity.setNd(String.valueOf(year));
		jcAjztTjJcEntity.setJcry(swryDm);
		jcAjztTjJcEntity.setSwjgDm(currentDeptId);
		
		jcAjztTjJcEntity.setPage(selectchiefReqVo.getPage());
		jcAjztTjJcEntity.setLimit(selectchiefReqVo.getLimit());
		
		
		IPage<JcAjztTjJcEntity> infoPage = jcAjztTjJcService.infoPage(jcAjztTjJcEntity);
		/*IPage<JcAjztTjJcDlEntity> infoPage = jcAjztTjJcDlService.infoPage(jcAjztTjJcEntity);*/
		// 是否申请公安联合办案
		List<JcAjztTjJcEntity> records = infoPage.getRecords();
		for (JcAjztTjJcEntity jcAjztTjJc : records) {
			String jcajxxuuid = jcAjztTjJc.getJcajxxuuid();
			WorkflowCompensateEntity workflowCompensate = workflowCompensateService.getByJcajxxuuid(jcajxxuuid);
			if(TsBqUtils.isNotNull(workflowCompensate)){
				jcAjztTjJc.setIsSqgalhba(workflowCompensate.getIsSqgalhba());
			}
			
		}
		
		return DataResult.success(infoPage);

	}

	@PostMapping("/three/jssl/zhustssl")
	@ResponseBody
	public DataResult threeJsslZhustssl(@RequestBody SelectchiefReqVo selectchiefReqVo) {
		// JC_AJZT_TJ_ZSTS
		String currentDeptId = httpSessionService.getCurrentDeptId();
		
		Calendar calendar = Calendar.getInstance();
		int year = calendar.get(Calendar.YEAR);
		String swryDm = selectchiefReqVo.getSwryDm();
		
		JcAjztTjZstsEntity jcAjztTjZstsEntity = new JcAjztTjZstsEntity();
		jcAjztTjZstsEntity.setNd(String.valueOf(year));
		jcAjztTjZstsEntity.setJcry(swryDm);
		jcAjztTjZstsEntity.setSwjgDm(currentDeptId);
		
		jcAjztTjZstsEntity.setPage(selectchiefReqVo.getPage());
		jcAjztTjZstsEntity.setLimit(selectchiefReqVo.getLimit());
		
		IPage<JcAjztTjZstsEntity> infoPage = jcAjztTjZstsService.infoPage(jcAjztTjZstsEntity);

		return DataResult.success(infoPage);
		
	}

	@PostMapping("/three/jssl/tsajsl")
	@ResponseBody
	public DataResult threeJsslTsajsl(@RequestBody SelectchiefReqVo selectchiefReqVo) {
		// JC_AJZT_TJ_SL
		String currentDeptId = httpSessionService.getCurrentDeptId();
		
		Calendar calendar = Calendar.getInstance();
		int year = calendar.get(Calendar.YEAR);
		String swryDm = selectchiefReqVo.getSwryDm();
		
		JcAjztTjSlEntity jcAjztTjSlEntity = new JcAjztTjSlEntity();
		jcAjztTjSlEntity.setNd(String.valueOf(year));
		jcAjztTjSlEntity.setJcry(swryDm);
		jcAjztTjSlEntity.setSwjgDm(currentDeptId);
		
		jcAjztTjSlEntity.setPage(selectchiefReqVo.getPage());
		jcAjztTjSlEntity.setLimit(selectchiefReqVo.getLimit());
		
		IPage<JcAjztTjSlEntity> infoPage = jcAjztTjSlService.infoPage(jcAjztTjSlEntity);
		/*IPage<JcAjztTjSlDlEntity> infoPage = jcAjztTjSlDlService.infoPage(jcAjztTjSlEntity);*/
		return DataResult.success(infoPage);
	}

	@PostMapping("/three/jssl/zzxajsl")
	@ResponseBody
	public DataResult threeJsslZzxajsl(@RequestBody SelectchiefReqVo selectchiefReqVo) {
		// JC_AJZT_TJ_ZX
		String currentDeptId = httpSessionService.getCurrentDeptId();
		
		Calendar calendar = Calendar.getInstance();
		int year = calendar.get(Calendar.YEAR);
		String swryDm = selectchiefReqVo.getSwryDm();
		
		JcAjztTjZxEntity jcAjztTjZxEntity = new JcAjztTjZxEntity();
		jcAjztTjZxEntity.setNd(String.valueOf(year));
		jcAjztTjZxEntity.setJcry(swryDm);
		jcAjztTjZxEntity.setSwjgDm(currentDeptId);
		
		jcAjztTjZxEntity.setPage(selectchiefReqVo.getPage());
		jcAjztTjZxEntity.setLimit(selectchiefReqVo.getLimit());
		
		IPage<JcAjztTjZxEntity> infoPage = jcAjztTjZxService.infoPage(jcAjztTjZxEntity);
		/*IPage<JcAjztTjZxDlEntity> infoPage = jcAjztTjZxDlService.infoPage(jcAjztTjZxEntity);*/
		return DataResult.success(infoPage);

	}

	@PostMapping("/three/jssl/zxwbsl")
	@ResponseBody
	public DataResult threeJsslZxwbsl(@RequestBody SelectchiefReqVo selectchiefReqVo) {
		// JC_AJZT_TJ_ZXWB
		String currentDeptId = httpSessionService.getCurrentDeptId();
		
		Calendar calendar = Calendar.getInstance();
		int year = calendar.get(Calendar.YEAR);
		String swryDm = selectchiefReqVo.getSwryDm();
		
		JcAjztTjZxwbEntity jcAjztTjZxwbEntity = new JcAjztTjZxwbEntity();
		jcAjztTjZxwbEntity.setNd(String.valueOf(year));
		jcAjztTjZxwbEntity.setJcry(swryDm);
		jcAjztTjZxwbEntity.setSwjgDm(currentDeptId);
		
		jcAjztTjZxwbEntity.setPage(selectchiefReqVo.getPage());
		jcAjztTjZxwbEntity.setLimit(selectchiefReqVo.getLimit());
		
		IPage<JcAjztTjZxwbEntity> infoPage = jcAjztTjZxwbService.infoPage(jcAjztTjZxwbEntity);
		/*IPage<JcAjztTjZxwbDlEntity> infoPage = jcAjztTjZxwbDlService.infoPage(jcAjztTjZxwbEntity);*/
		return DataResult.success(infoPage);

	}

	@PostMapping("/three/jssl/zhzjcsl")
	@ResponseBody
	public DataResult threeJsslZhzjcsl(@RequestBody SelectchiefReqVo selectchiefReqVo) {
		// JC_AJZT_TJ_ZJJC
		String currentDeptId = httpSessionService.getCurrentDeptId();
		
		Calendar calendar = Calendar.getInstance();
		int year = calendar.get(Calendar.YEAR);
		String swryDm = selectchiefReqVo.getSwryDm();
		
		JcAjztTjZjjcEntity jcAjztTjZjjcEntity = new JcAjztTjZjjcEntity();
		jcAjztTjZjjcEntity.setNd(String.valueOf(year));
		jcAjztTjZjjcEntity.setJcry(swryDm);
		jcAjztTjZjjcEntity.setSwjgDm(currentDeptId);
		
		jcAjztTjZjjcEntity.setPage(selectchiefReqVo.getPage());
		jcAjztTjZjjcEntity.setLimit(selectchiefReqVo.getLimit());
		
		IPage<JcAjztTjZjjcEntity> infoPage = jcAjztTjZjjcService.infoPage(jcAjztTjZjjcEntity);
		/*IPage<JcAjztTjZjjcDlEntity> infoPage = jcAjztTjZjjcDlService.infoPage(jcAjztTjZjjcEntity);*/
		return DataResult.success(infoPage);
		
	}

	@PostMapping("/three/jssl/bjsl")
	@ResponseBody
	public DataResult threeJsslBjsl(@RequestBody SelectchiefReqVo selectchiefReqVo) {
		// JC_AJZT_TJ_BJ
		String currentDeptId = httpSessionService.getCurrentDeptId();
		
		Calendar calendar = Calendar.getInstance();
		int year = calendar.get(Calendar.YEAR);
		String swryDm = selectchiefReqVo.getSwryDm();
		
		JcAjztTjBjEntity jcAjztTjBjEntity = new JcAjztTjBjEntity();
		jcAjztTjBjEntity.setNd(String.valueOf(year));
		jcAjztTjBjEntity.setJcry(swryDm);
		jcAjztTjBjEntity.setSwjgDm(currentDeptId);
		
		jcAjztTjBjEntity.setPage(selectchiefReqVo.getPage());
		jcAjztTjBjEntity.setLimit(selectchiefReqVo.getLimit());
		
		IPage<JcAjztTjBjEntity> infoPage = jcAjztTjBjService.infoPage(jcAjztTjBjEntity);
		/*IPage<JcAjztTjBjDlEntity> infoPage = jcAjztTjBjDlService.infoPage(jcAjztTjBjEntity);*/
		return DataResult.success(infoPage);
	}

}
